top_10_songs_released_2023 <- data %>%
  filter(released_year == 2023) %>%
  arrange(desc(streams)) %>%
  head(10) %>%
  select(track_name, artist_name, streams)
top_10_songs_released_2023
##                               track_name                artist_name    streams
## 1                                Flowers                Miley Cyrus 1316855716
## 2                        Ella Baila Sola Eslabon Armado, Peso Pluma  725980112
## 3  Shakira: Bzrp Music Sessions, Vol. 53          Shakira, Bizarrap  721975598
## 4                                    TQG           Karol G, Shakira  618990393
## 5                        La Bebe - Remix      Peso Pluma, Yng Lvcas  553634067
## 6                    Die For You - Remix  Ariana Grande, The Weeknd  518745108
## 7                              un x100to  Bad Bunny, Grupo Frontera  505671438
## 8                      Cupid - Twin Ver.                Fifty Fifty  496795686
## 9                                    PRC  Natanael Cano, Peso Pluma  436027885
## 10                                   OMG                   NewJeans  430977451
top_10_songs_2023 <- data %>%
  arrange(desc(streams)) %>%
  head(10) %>%
  select(track_name, released_year, artist_name, streams)
top_10_songs_2023
##                                       track_name released_year
## 1                                Blinding Lights          2019
## 2                                   Shape of You          2017
## 3                              Someone You Loved          2018
## 4                                   Dance Monkey          2019
## 5  Sunflower - Spider-Man: Into the Spider-Verse          2018
## 6                                      One Dance          2016
## 7                      STAY (with Justin Bieber)          2021
## 8                                       Believer          2017
## 9                                         Closer          2016
## 10                                       Starboy          2016
##                     artist_name    streams
## 1                    The Weeknd 3703895074
## 2                    Ed Sheeran 3562543890
## 3                 Lewis Capaldi 2887241814
## 4                   Tones and I 2864791672
## 5         Post Malone, Swae Lee 2808096550
## 6           Drake, WizKid, Kyla 2713922350
## 7  Justin Bieber, The Kid Laroi 2665343922
## 8               Imagine Dragons 2594040133
## 9      The Chainsmokers, Halsey 2591224264
## 10        The Weeknd, Daft Punk 2565529693
top_10_songs_released_2023$type <- "Released in 2023"
top_10_songs_2023$type <- "Top 10 Overall"


combined_data <- bind_rows(top_10_songs_released_2023, top_10_songs_2023)

combined_data <- combined_data %>%
  group_by(type) %>%
  mutate(position = row_number())

p <- ggplot(combined_data, aes(x = position, y = streams/100000, group = type, color = type, linetype = type, text = paste("Track Name:", track_name, "<br>Artist:", artist_name))) +
  geom_line(size = 1.5) +
  geom_point(size = 3) +
  scale_x_continuous() +
  labs(title = "Top 10 Songs by Streams",
       x = "Track Position",
       y = "Number of Streams",
       color = "Category",
       linetype = "Category") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1),
        legend.position = "bottom")
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
ggplotly(p, tooltip = "text")